package com.forest.server.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author: Forest
 * @Date: 2017/2/14 21:22
 */
@RestController
public class UserController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Resource
    private DiscoveryClient client;

    @RequestMapping(value = "/info",method = RequestMethod.GET)
    public String info(@RequestParam String a,@RequestParam String b){
        ServiceInstance instance = client.getLocalServiceInstance();
        String str = a +"@"+b;
        logger.info("/info,host:{},service_id:{}",instance.getHost(),instance.getServiceId());
        return str;
    }
}
